<template>
  <div>
      <div class="list" v-for="(list, index) in List" :key="list.id">
          <slot name="num" :index="index" ></slot>
      <!-- <div class="list" v-for="(list, index) in List" :key="list.id">
        <div class="num" v-if="isShow">
          {{ index + 1 }}
        </div>
        <div class="num" :class="{ 'color-red': index < 3 }" v-else>
        {{ index > 8 ? index + 1 : "0" + (index + 1) }}
      </div> -->
        <div class="list-item" @click="playMusic(list)">
          <div class="left">
            <div class="subtitle">
              {{ list.name }}
              <span>{{ list.alia[0] }}</span>
            </div>
            <div class="author">
              <span v-for="(ele, index) in list.ar" :key="ele.id"
                >{{ ele.name
                }}{{ list.ar.length - 1 === index ? "" : " / " }}</span
              >
              <span> - {{ list.al.name }}</span>
            </div>
          </div>
          <div class="right"><img src="@/assets/images/play.png" alt="" /></div>
        </div>
      </div>
    </div>
</template>

<script>
export default {
  name: "MusicList",
    props:{
        List:{
            type:Array,
            default:function(){
                return []
            }
        },
        isShow:{
            type:Boolean,
            default:true
        }
    },
    methods:{
        playMusic(val){
            this.$router.push({
                name:'songpage',
                params:{id:val.id,title:val.name}
            })
        }
    }
};
</script>

<style lang="less" scoped>

  .list {
    display: flex;
    height: 1.2rem;

    .num {
      color: #999;
      flex-shrink: 0;
      width: 1rem;
      display: flex;
      font-size: 17px;
      align-items: center;
      justify-content: center;
      text-align: center;  }
      .color-red{
          color:#df3436;
      }
  
    .list-item {
      border-bottom: 1px solid #eee;
      padding-top: 6px;
      padding-bottom: 6px;
      display: flex;
      flex: 1;
      width: 6.5rem;
      .left {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        word-break: normal;
      }
      .subtitle {
        font-size: 17px;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        word-break: normal;

        span {
          color: #888;
        }
      }
      .author {
        margin-top: 4px;
        font-size: 12px;
        color: #888;
      }

      .right {
        align-items: center;
        justify-content: center;
        width: 0.9rem;
        display: flex;
        img {
          width: 0.6rem;
          height: 0.6rem;
        }
      }
    }
  }

</style>
